<script lang="ts" setup>
import { ref, onUnmounted } from "vue";
import Child from './Child.vue'
import emitter from '@/views/utils/emitter'

defineOptions({
    name: "index",
});
//--================= Data

let toy = "奥特曼C";


//--================= Methods
// function ClickChildButton() {
//     emitter.emit('send-toy')
// }

//--================= Other

emitter.on('send-Userinfo', () => {
    console.log("Send Userinfo");
})

onUnmounted(() => {
    emitter.off("send-Userinfo")
})

</script>

<template>
    <div class="main">
        <h3>父组件</h3>
        <button @click="emitter.emit('send-toy', 'hello wrold!')"> 调用子组件的button</button> <br><br><br>
        <Child title="Hello Child" />

    </div>
</template>

<style scoped>
.main {
    background-color: #eee;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    min-height: 500px;
}
</style>
